//
//  processedFoodFactory.swift
//  Victoria3
//
//  Created by lhc on 2023/11/24.
//

import Foundation

class ProcessedFoodFactory {
    
    struct FoodType {
        let name: String
        let value: Int
    }
    
    static private let baseType = [
        FoodType(name: "面包房", value: 550),
        FoodType(name: "甜味剂", value: 700),
        FoodType(name: "发酵粉", value: 1100)
    ]
    

    static private let canType = [
        FoodType(name: "无罐头", value: 0),
        FoodType(name: "鱼罐头", value: 300),
        FoodType(name: "肉罐头", value: 600)
    ]
    
    static private let alcoholType = [
        FoodType(name: "无酒", value: 0),
        FoodType(name: "糖制酒", value: 150),
        FoodType(name: "玻璃糖制酒", value: 650)
    ]
    
    static func calculate() -> [(String, Int)] {
        
        var result = [(String, Int)]()
        
        for i in Self.baseType {
            
            for j in Self.canType {
                
                for k in Self.alcoholType {
                    
                    let value = i.value + j.value + k.value
                    let description = "\(i.name) + \(j.name) + \(k.name)"
                    result.append((description, value))
                }
            }
        }
        
        result.sort { first, last in
            return first.1 > last.1
        }
        
        return result
    }
}
